]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
windowManager: Handle window dimming animation getting cancelled
authorJonas Dreßler <verdre@v0yd.nl>
Thu, 30 Jun 2022 07:40:51 +0000 (09:40 +0200)
committerMarge Bot <marge-bot@gnome.org>
Sat, 2 Jul 2022 00:39:49 +0000 (00:39 +0000)
When a window with a modal dialog gets minimized and at the same time
the dialog is closed, the WindowDimmer undim animation starts and gets
cancelled when the minimize animation is done, because that unmaps the
window actor.

In this case we want ensure the dimming effect still goes into a
proper state instead of being stuck mid-animation, so listen to
onStopped instead of onComplete for syncing state of the window dimmer.

While at it, clean things up a little and move the check for the
attach-modal-dialogs pref inside the _syncEnabled() function.

Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5581

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2349>

js/ui/windowManager.js

index bd47e6e5d562deee71d4fa3ce29493043e57cce9..2050ff8ab52d489b877e9f73637ab4aa549b5d46 100644 (file)
@@ -132,18 +132,12 @@ class WindowDimmer extends Clutter.BrightnessContrastEffect {
             name: WINDOW_DIMMER_EFFECT_NAME,
             enabled: false,
         });
-        this._enabled = true;
     }
 
-    _syncEnabled() {
+    _syncEnabled(dimmed) {
         let animating = this.actor.get_transition(`@effects.${this.name}.brightness`) !== null;
-        let dimmed = this.brightness.red != 127;
-        this.enabled = this._enabled && (animating || dimmed);
-    }
 
-    setEnabled(enabled) {
-        this._enabled = enabled;
-        this._syncEnabled();
+        this.enabled = Meta.prefs_get_attach_modal_dialogs() && (animating || dimmed);
     }
 
     setDimmed(dimmed, animate) {
@@ -153,20 +147,17 @@ class WindowDimmer extends Clutter.BrightnessContrastEffect {
         this.actor.ease_property(`@effects.${this.name}.brightness`, color, {
             mode: Clutter.AnimationMode.LINEAR,
             duration: (dimmed ? DIM_TIME : UNDIM_TIME) * (animate ? 1 : 0),
-            onComplete: () => this._syncEnabled(),
+            onStopped: () => this._syncEnabled(dimmed),
         });
 
-        this._syncEnabled();
+        this._syncEnabled(dimmed);
     }
 });
 
 function getWindowDimmer(actor) {
-    let enabled = Meta.prefs_get_attach_modal_dialogs();
     let effect = actor.get_effect(WINDOW_DIMMER_EFFECT_NAME);
 
-    if (effect) {
-        effect.setEnabled(enabled);
-    } else if (enabled) {
+    if (!effect) {
         effect = new WindowDimmer();
         actor.add_effect(effect);
     }